import  { uni_color_primary, uni_color_success, uni_color_warning, uni_color_erroe} from './../styles/variables.scss';


/**
 * @description 返回这个样式的颜色值
 * @param {String} type 样式名称 [ primary | success | warning | error | text ]
 */
 function typeColor (type = 'default') {
    let color = '';
    switch (type) {
    case 'default': color = '#515a6e'; break;
    case 'primary': color = uni_color_primary; break;
    case 'success': color = uni_color_success; break;
    case 'warning': color = uni_color_warning; break;
    case 'error': color = uni_color_erroe; break;
    default:; break
    }
    return color;
}

const log ={}


/**
 * @description 打印彩色文字
 */
 log.colorful = function (textArr) {
    console.log(
        `%c${textArr.map(t => t.text || '').join('%c')}`,
        ...textArr.map(t => `color: ${typeColor(t.type)}`)
    );
};

/**
 * @description 打印 primary 样式的文字
 */
 log.primary = function (text) {
    log.colorful([{ text, type: 'primary' }]);
};

/**
 * @description 打印 success 样式的文字
 */
log.success = function (text) {
    log.colorful([{ text, type: 'success' }]);
};

/**
 * @description 打印 warning 样式的文字
 */
log.warning = function (text) {
    log.colorful([{ text, type: 'warning' }]);
};

/**
 * @description 打印 error 样式的文字
 */
log.error = function (text) {
    console.log(text);
    log.colorful([{ text, type: 'error' }]);
};

export default log;